import base64
import json
import os
from typing import Any
import pandas
import re
from ..llm.cloudAPI import SiliconFlowAPI

config: Any

class TableExtractionConfig:
    """Configuration class for table data extraction"""
    def __init__(self, columns: list[str], table_description: str = "table", extraction_instructions: str = None, data_types: dict[str, str] = None, vision_model: str = "Qwen/Qwen2.5-VL-32B-Instruct", temperature: float = 0.1, max_tokens: int = 4096):
        """
        Initialize table extraction configuration
        
        Args:
            columns: List of column names to extract
            table_description: Description of what kind of table this is
            extraction_instructions: Custom instructions for data extraction
            data_types: Dictionary mapping column names to expected data types
                       ("string", "number", "date", "boolean")
            vision_model: Vision model to use for extraction
            temperature: Model temperature for generation
            max_tokens: Maximum tokens for model response
        """
        ...
    def generate_extraction_prompt(self) -> str:
        """Generate the extraction prompt based on configuration"""
        ...

class ExtractTableDataByImages:
    """Extract table data from images using LLM"""
    def __init__(self, images_path: Any, extraction_config: TableExtractionConfig, api_key: str = None, images_prefix: Any = None):
        """
        Args:
            images_path: List of image file paths
            extraction_config: Table extraction configuration.
            api_key: SiliconFlow API key
            images_prefix: Prefix to filter images. If provided, only images whose filename starts with this prefix will be processed.
        """
        ...
    def process(self) -> pd.DataFrame:
        """
        Process the input images and extract table data
        
        Returns:
            pandas DataFrame with extracted table data
        """
        ...
